/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ages.math
import Math.sqrt

//This class is IMMUTABLE
case class Vector3D (override X:Double,override Y:Double,override Z:Double) extends Vector{

  def this() = {
    this(0,0,0)
  }

  def coordsFromString(s:String)
  {
    
  }

    def plus(v:Vector):Vector = Vector3D(X+v.X,Y+v.Y,Z+v.Z)
    def minus(v:Vector):Vector = Vector3D(X-v.X,Y-v.Y,Z-v.Z)
    def mul(v:Vector):Vector = Vector3D(X*v.X,Y*v.Y,Z*v.Z)
    def dot(i:Double):Vector = Vector3D(X*i,Y*i,Z*i)
    def coords = List(X,Y,Z)
    def length = sqrt(X*X+Y*Y+Z*Z)
    def unit = this dot (1/this.length)
}

object Vector3D {
  def newFromString(s:String)
  {
    val strip = s.replace("(","").replace(")","")
    val split = s.split(",")
    Vector3D(split(0).toDouble,split(1).toDouble,split(2).toDouble)
  }
}